package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {

    //根据传入的时间 获得对象  但是必须数据库造一条昨天的数据
    @Select("select * from tb_analysis_by_day where record_date = #{date}")
    AnalysisByDay findByDateTime(String date);

    //累计用户
    @Select("SELECT SUM(num_registered) FROM `tb_analysis_by_day`")
    Long findCountSumRegister();

    //查询指定日期到今天的活跃用户数
    @Select("SELECT SUM(num_active) FROM `tb_analysis_by_day` WHERE `record_date` BETWEEN #{date} AND #{today};")
    Long findCountSubActive(@Param("date") String date,@Param("today") String today);

    /*@Select("SELECT SUM(num_active) FROM tb_analysis_by_day WHERE record_date BETWEEN #{startDate} AND #{endDate}")
    long queryActiveUsers(@Param("startDate") Date start, @Param("endDate") Date end);*/

}